<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            // let arr = [1, 2, 3, 4, 5];
            // let arr2 = [1, 2, [3, 4]];
            // let arr3 = arr.concat(arr2);
            // console.log(arr3); // [1, 2, 3, 4, 5, 1, 2, Array(2)]
            // console.log(arr); // [1, 2, 3, 4, 5]
            // console.log(arr2); // [1, 2, Array(2)]

            Array.prototype.myConcat = function (...args) {
                let result = [...this];
                args.forEach((item, index) => {
                    if (Array.isArray(item)) {
                        result.push(...item);
                    } else {
                        result.push(item);
                    }
                });
                return result;
            };
            let arr = [1, 2, 3, 4, 5];
            let arr2 = [1, 2, [3, 4]];
            let arr3 = arr.concat(arr2);
            console.log(arr3); // [1, 2, 3, 4, 5, 1, 2, Array(2)]
            console.log(arr); // [1, 2, 3, 4, 5]
            console.log(arr2); // [1, 2, Array(2)]
        </script>
    </body>
</html>
